<div class="container edit-page">
  <div class="row user-form">
    <div class="col-md-12 col-lg-9">
      <%= form_for @changeset, Routes.user_path(@conn, :update), [class: "simple_form form-horizontal", novalidate: "novalidate", role: "form"], fn f -> %>
        <legend>Account settings</legend>

        <div class="form-group row string optional user_username <%= error_class(f, :username) %>">
          <%= label f, :username, class: "string optional col-form-label col-sm-3 col-md-3 col-lg-2" %>
          <div class="col-sm-9 col-md-9 col-lg-10">
            <%= text_input f, :username, class: "string optional form-control" %>
            <%= error_tag f, :username %>
          </div>
        </div>

        <div class="form-group row email required user_email <%= error_class(f, :email) %>">
          <%= label f, :email, class: "email required col-form-label col-sm-3 col-md-3 col-lg-2" %>
          <div class="col-sm-9 col-md-9 col-lg-10">
            <%= email_input f, :email, class: "string email required form-control" %>
            <%= error_tag f, :email %>
          </div>
        </div>

        <div class="form-group row string optional user_name <%= error_class(f, :name) %>">
          <%= label f, :name, "Full name", class: "string optional col-form-label col-sm-3 col-md-3 col-lg-2" %>
          <div class="col-sm-9 col-md-9 col-lg-10">
            <%= text_input f, :name, class: "string optional form-control" %>
            <%= error_tag f, :name %>
          </div>
        </div>

        <div class="form-group row select optional user_theme_name">
          <%= label f, :theme_name, "Terminal theme", class: "select optional col-form-label col-sm-3 col-md-3 col-lg-2" %>
          <div class="col-sm-9 col-md-9 col-lg-10">
            <%= select f, :theme_name, theme_options(), class: "select optional form-control", prompt: "Default (asciinema)" %>
            <small class="form-text text-muted">Applies to all your asciicasts unless custom theme chosen for a specific asciicast</small>
          </div>
        </div>

        <div class="form-group row radio_buttons optional user_asciicasts_private_by_default">
          <%= label f, :asciicasts_private_by_default, "Asciicast visibility", class: "radio_buttons optional col-form-label col-sm-3 col-md-3 col-lg-2" %>
          <div class="col-sm-9 col-md-9 col-lg-10">
            <div class="form-check">
              <%= radio_button f, :asciicasts_private_by_default, false, class: "radio_buttons optional form-check-input" %>
              <%= label f, :asciicasts_private_by_default, "public", for: "user_asciicasts_private_by_default_false", class: "form-check-label" %>
            </div>
            <div class="form-check">
              <%= radio_button f, :asciicasts_private_by_default, true, class: "radio_buttons optional form-check-input" %>
              <%= label f, :asciicasts_private_by_default, "private", for: "user_asciicasts_private_by_default_true", class: "form-check-label" %>
            </div>
            <small class="form-text text-muted">Applies to all *new* asciicasts</small>
          </div>
        </div>

        <div class="form-group row">
          <label class="col-form-label col-sm-3 col-md-3 col-lg-2"></label>
          <div class="col-sm-offset-3 col-sm-9 col-md-offset-3 col-md-9 col-lg-offset-2 col-lg-10">
            <%= submit "Save", class: "btn btn-primary" %>
            <%= link "Cancel", to: profile_path(@conn), class: "btn" %>
          </div>
        </div>
      <% end %>
    </div>
  </div>

  <div class="row tokens-list">
    <div class="col-md-12">
      <legend>Recorder tokens</legend>

      <%= if present?(@api_tokens) do %>
        <p>
          The following recorder tokens have been associated with your account:
        </p>

        <ul>
          <%= for t <- active_tokens(@api_tokens) do %>
            <li><code><%= t.token %></code> registered <%= time_tag(t.inserted_at) %> - <%= link "Revoke", to: Routes.api_token_path(@conn, :delete, t), method: "delete", data: [confirm: "Are you sure?"] %></li>
          <% end %>
        </ul>

        <ul>
          <%= for t <- revoked_tokens(@api_tokens) do %>
            <li class="revoked-token"><code><%= t.token %></code> registered <%= time_ago_tag(t.inserted_at) %>, revoked <%= time_ago_tag(t.revoked_at) %>
          <% end %>
        </ul>
      <% else %>
        <p>
          If you want your recordings to be assigned to your profile
          you have to register your local recorder token.
        </p>

        <p>
          There is currently no recorder token associated with your account.
          Run <code>asciinema auth</code> in your terminal to register one.
        </p>
      <% end %>
    </div>
  </div>
</div>
